package project1.service;

import project1.dao.AdminDao;
import project1.dao.AdminDaoIml;
import project1.model.Admin;
import project1.model.bo.AdminAddBO;
import project1.model.bo.AdminLoginBO;
import project1.model.bo.AdminSearchBO;

import java.util.List;

public class AdminServiceImpl implements AdminService {
    private AdminDao adminDao = new AdminDaoIml();
    @Override
    public Admin login(AdminLoginBO loginBO) {
        Admin admin = new Admin();
        admin.setEmail(loginBO.getEmail());
        admin.setPwd(loginBO.getPwd());
        return adminDao.login(admin);
    }

    @Override
    public List<Admin> allAdmins() {
        return adminDao.allAdmins();
    }

    @Override
    public List<Admin> getSearchAdmins(AdminSearchBO searchBO) {
        Admin admin = new Admin();
        admin.setEmail(searchBO.getEmail());
        admin.setNickname(searchBO.getNickname());
        return adminDao.getSearchAdmins(admin);

    }

    @Override
    public void deleteAdmin(String id) {
         adminDao.deleteAdmin(id);
    }

    @Override
    public void addAdmin(AdminAddBO adminAddBO) {
        Admin admin = new Admin();
        admin.setEmail(adminAddBO.getEmail());
        admin.setPwd(adminAddBO.getPwd());
        admin.setNickname(adminAddBO.getNickname());
       adminDao.addAdmin(admin);
    }

    @Override
    public Admin getAdminInfo(String id) {
        return adminDao.getAdminInfo(id);
    }

    @Override
    public void updateAdmin(Admin admin) {
        adminDao.updateAdmin(admin);
    }
}
